package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApArticleConfigMapper;
import com.heima.article.service.ApArticleConfigService;
import com.heima.model.article.pojos.ApArticleConfig;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.Map;

/**
 * @author 石头
 * @description 针对表【ap_article_config(APP已发布文章配置表)】的数据库操作Service实现
 * @createDate 2022-06-16 17:20:59
 */
@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig>
        implements ApArticleConfigService {


    /**
     * 修改文章配置
     *
     * @param map
     */
    @Override
    public void updateConfigMap(Map map) {
        //0 下架 1 上架
        Object enable = map.get("enable");
        Integer isDown = 1;
        if (enable.equals(1)) {
            isDown = 0;
        }
        this.update(Wrappers.<ApArticleConfig>lambdaUpdate().eq(ApArticleConfig::getArticleId, map.get("articleId")).set(ApArticleConfig::getIsDown, isDown));
    }
}




